﻿using Infra_Common.redis;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace xiaodingmarket_service.Configurations
{
    public static class RedisExtensions
    {
		public static void ConfigDefaultRedis(this IServiceCollection services, IConfiguration configuration)
		{
			//var section = configuration.GetSection("Redis:Default");
			//string _connectionString = section.GetSection("Connection").Value;
			//string _instanceName = section.GetSection("InstanceName").Value;
			//int _defaultDB = int.Parse(section.GetSection("DefaultDB").Value ?? "0");
			//RedisClient DefaultRedis = new RedisClient(_connectionString, _instanceName, _defaultDB);
			//services.AddSingleton(DefaultRedis);

			var section1 = configuration.GetSection("Redis:Review");
			string _connectionString1 = section1.GetSection("Connection").Value;
			string _instanceName1 = section1.GetSection("InstanceName").Value;
			int _defaultDB1 = int.Parse(section1.GetSection("DefaultDB").Value ?? "0");
			RedisClient ReviewRedis = new RedisClient(_connectionString1, _instanceName1, _defaultDB1);
			services.AddSingleton(ReviewRedis);
		}
	}
}
